﻿using GBT.Business.GBT_Base_Manage;
using GBT.Entity;
using GBT.Entity.GBT_Base_Manage;
using GBT.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace GBT.AmoebaManage.Controllers.GBT_Base_Manage
{
    [Route("/GBT_Base_Manage/[controller]/[action]")]
    public class GBT_Base_ServiceItemsController : BaseApiController
    {
        #region DI

        public GBT_Base_ServiceItemsController(IGBT_Base_ServiceItemsBusiness gBT_Base_ServiceItemsBus)
        {
            _gBT_Base_ServiceItemsBus = gBT_Base_ServiceItemsBus;
        }

        IGBT_Base_ServiceItemsBusiness _gBT_Base_ServiceItemsBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<GBT_Base_ServiceItemsDTO>> GetDataList(PageInput<GBT_Base_ServiceItemConditionDTO> input)
        {
            return await _gBT_Base_ServiceItemsBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<GBT_Base_ServiceItems> GetTheData(IdInputDTO input)
        {
            return await _gBT_Base_ServiceItemsBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(GBT_Base_ServiceItems data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _gBT_Base_ServiceItemsBus.AddDataAsync(data);
            }
            else
            {
                await _gBT_Base_ServiceItemsBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _gBT_Base_ServiceItemsBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}